package com.weareint.biz.dto;

import com.weareint.biz.entity.Printer;
import com.weareint.common.dto.AbstractDTO;
import com.weareint.common.dto.IBasicDTO;
import com.weareint.common.utils.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 *
 *
 * <pre>
 *      打印机DTO
 * </pre>
 *
 * @author Auto Generator
 * @date 2021-07-28
 */
@ApiModel(value = "打印机", description = "打印机")
@Data
@EqualsAndHashCode(callSuper = true)
public class PrinterDTO extends AbstractDTO implements IBasicDTO<Printer> {

    @ApiModelProperty(value = "打印机IP地址")
    private String ip;

    @ApiModelProperty(value = "打印机编码")
    private String code;

    @ApiModelProperty(value = "打印机端口")
    private Integer port;

    @ApiModelProperty(value = "状态：0禁用，1启用")
    private Integer state;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "使用类型：1表示大箱打印机，2表示小盒打印机")
    private Integer useType;

    @ApiModelProperty(value = "是否支持手动打印：0表示不支持手动打印，1表示支持手动打印")
    private Integer manualPrintEnabled;


    /**
     * <pre>
     *     转化为Entity对象
     * </pre>
     * @return {@link Printer}
     */
    @Override
    public Printer toEntity() {
        Printer entity = new Printer();
        entity.setId(this.getId());
        entity.setIp(this.getIp());
        entity.setCode(this.getCode());
        entity.setPort(this.getPort());
        entity.setState(this.getState());
        entity.setRemark(this.getRemark());
        entity.setUseType(this.getUseType());
        entity.setManualPrintEnabled(this.getManualPrintEnabled());
        return entity;
    }

    /**
     * <pre>
     *     依据非空的属性创建一个新Entity
     * </pre>
     * @return {@link Printer}
     */
    @Override
    public Printer toNewEntityIgnoreNulls() {
        Printer unPersistentEntity = new Printer();
        toEntityIgnoreNulls(unPersistentEntity);
        return unPersistentEntity;
    }

    /**
     * <pre>
     *     把非空的属性复制到已有的实体上
     * </pre>
     * @param persistentEntity {@link Printer}
     */
    @Override
    public void toEntityIgnoreNulls(Printer persistentEntity) {
        if (null != this.getCreateTime()){
            persistentEntity.setCreateTime(DateUtil.parse(this.getCreateTime()));
        }
        if (null != this.getUpdateTime()){
            persistentEntity.setUpdateTime(DateUtil.parse(this.getUpdateTime()));
        }
        if (null != this.getCreator()){
            persistentEntity.setCreator(this.getCreator());
        }
        if (null != this.getUpdater()){
            persistentEntity.setUpdater(this.getUpdater());
        }
        if (null != this.getId()){
            persistentEntity.setId(this.getId());
        }
        if (null != this.getIp()){
            persistentEntity.setIp(this.getIp());
        }
        if (null != this.getCode()){
            persistentEntity.setCode(this.getCode());
        }
        if (null != this.getPort()){
            persistentEntity.setPort(this.getPort());
        }
        if (null != this.getState()){
            persistentEntity.setState(this.getState());
        }
        if (null != this.getRemark()){
            persistentEntity.setRemark(this.getRemark());
        }
        if (null != this.getUseType()){
            persistentEntity.setUseType(this.getUseType());
        }
        if (null != this.getManualPrintEnabled()){
            persistentEntity.setManualPrintEnabled(this.getManualPrintEnabled());
        }
    }


}
